package com.maozzi.service.user.domain.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.maozzi.service.user.domain.UserDomainService;
import com.maozzi.service.user.repository.mapper.UserMapper;
import com.maozzi.service.user.repository.model.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * user domain service
 *
 * @author maozi
 */
@Service
public class UserDomainServiceImpl implements UserDomainService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User getUser(Long userId) {
        return userMapper.selectById(userId);
    }

    @Override
    public User getUser(String name, String password) {
        return userMapper.selectOne(Wrappers.lambdaQuery(User.class)
                .eq(User::getName, name)
                .eq(User::getPassword, password)
                .eq(User::getDeleted, Boolean.FALSE)
        );
    }
}
